// var i;
// var $uI_BoxInfo_UIBindings = require("./UI_BoxInfo_UIBindings.ts");
// var $uIView = require("./UIView");
// var $excel = require("./Excel");
// var $hallManager = require("./HallManager");
// var $uIManager = require("./UIManager");
// var $bundleConfig = require("./BundleConfig");
// var $uIConfig_Home = require("./UIConfig_Home");
// var $playerDataManager = require("./PlayerDataManager");
// var g = cc._decorator;
// var _ = g.ccclass;
// var y = g.property;
// var m = g.inspector;
// var v = (function (e) {
//     function t() {
//         var t = (null !== e && e.apply(this, arguments)) || this;
//         t.auto_ui = null;
//         return t;
//     }
//     __extends(t, e);
//     t.prototype._show = function (e) {
//         this.infoData = e;
//         var t = $excel.Excel.shopBoxLevel($hallManager.HallMgr.shopData.boxLevel + 1);
//         if (0 == e.type) {
//             this.auto_ui.txt_titleLabel.string = "普通礼盒";
//         } else {
//             this.auto_ui.txt_titleLabel.string = "精致礼盒";
//         }
//         var o;
//         if (0 == e.type) {
//             o = t.moneyCount;
//         } else {
//             o = t.bigMoneyCount;
//         }
//         var n;
//         if (0 == e.type) {
//             n = t.rewards;
//         } else {
//             n = t.bigRewards;
//         }
//         this.auto_ui.txt_goldLabel.node.parent.active = o > 0;
//         this.auto_ui.txt_goldLabel.string = "" + o;
//         this.auto_ui.txt_lvLabel.node.parent.active = n[0] > 0;
//         this.auto_ui.txt_lvLabel.string = "" + n[0];
//         this.auto_ui.txt_lanLabel.node.parent.active = n[1] > 0;
//         this.auto_ui.txt_lanLabel.string = "" + n[1];
//         this.auto_ui.txt_ziLabel.node.parent.active = n[2] > 0;
//         this.auto_ui.txt_ziLabel.string = "" + n[2];
//         this.auto_ui.node_boxBG.children[0].active = 0 == e.type;
//         this.auto_ui.node_boxBG.children[1].active = 1 == e.type;
//         var i = $excel.Excel.shopControl(1);
//         if (0 == e.type) {
//             this.auto_ui.btn_videoBuyBtn.interactable = i.box1BuyCount - $hallManager.HallMgr.shopData.box1BuyCount > 0;
//         } else {
//             this.auto_ui.btn_videoBuyBtn.interactable = i.box2BuyCount - $hallManager.HallMgr.shopData.box2BuyCount > 0;
//         }
//         this.auto_ui.txt_priceLabel.string = "" + (0 == e.type ? i.boxPrice : i.bigBoxPrice);
//         if (0 == e.type) {
//             this.auto_ui.btn_buyBtn.interactable = $playerDataManager.PlayerDataMgr.globalData.diamond >= i.boxPrice;
//         } else {
//             this.auto_ui.btn_buyBtn.interactable = $playerDataManager.PlayerDataMgr.globalData.diamond >= i.bigBoxPrice;
//         }
//     };
//     t.prototype._clickListener = function (e) {
//         var t = this;
//         switch (e) {
//             case this.auto_ui.btn_buyBtn:
//                 if (this.infoData && this.infoData.clickCallBack) {
//                     this.infoData.clickCallBack(!1);
//                     this._close();
//                 }
//                 break;
//             case this.auto_ui.btn_videoBuyBtn:
//                 if (this.infoData && this.infoData.clickCallBack) {
//                     this.infoData.clickCallBack(function () {
//                         t._close();
//                     });
//                 }
//                 break;
//             case this.auto_ui.btn_closeBtn:
//                 this._close();
//                 break;
//             case this.auto_ui.btn_lvIconBtn:
//                 this.ShowEquipInfo(1);
//                 break;
//             case this.auto_ui.btn_lanIconBtn:
//                 this.ShowEquipInfo(2);
//                 break;
//             case this.auto_ui.btn_ziIconBtn:
//                 this.ShowEquipInfo(3);
//         }
//     };
//     t.prototype.ShowEquipInfo = function (e) {
//         $uIManager.default.open($bundleConfig.BundleNames.Home, $uIConfig_Home.UIView_Home.UI_BoxItemInfo, e);
//     };
//     __decorate([y($uI_BoxInfo_UIBindings.default)], t.prototype, "auto_ui", void 0);
//     return __decorate([_], t);
// })($uIView.default);
// exports.default = v;



// import UI_BoxInfo_UIBindings from "./UI_BoxInfo_UIBindings";
// import UIView from "./UIView";
// import { Excel } from "./Excel";
// import { HallMgrInstance } from "./HallManager";
// import UIManager from "./UIManager";
// import { BundleNames } from "./BundleConfig";
// import { PlayerDataMgr } from "./PlayerDataManager";
// import { UIView_Home } from "./UIConfig_Home";

// const { ccclass, property, inspector } = cc._decorator;

// /**
//  * 建议类名: BoxInfoView
//  */
// @ccclass
// class UI_BoxInfo extends UIView {
//     @property(UI_BoxInfo_UIBindings)
//     auto_ui: UI_BoxInfo_UIBindings = null;

//     private infoData: any;

//     /**
//      * 显示礼盒信息
//      * @param e 礼盒信息数据
//      * 建议方法名: showBoxInfo
//      */
//     _show(e: any): void {
//         this.infoData = e;
//         const shopBoxLevelData = Excel.shopBoxLevel(HallMgrInstance.shopData.boxLevel + 1);

//         if (e.type === 0) {
//             this.auto_ui.txt_titleLabel.string = "普通礼盒";
//         } else {
//             this.auto_ui.txt_titleLabel.string = "精致礼盒";
//         }

//         const moneyCount = e.type === 0 ? shopBoxLevelData.moneyCount : shopBoxLevelData.bigMoneyCount;
//         const rewards = e.type === 0 ? shopBoxLevelData.rewards : shopBoxLevelData.bigRewards;

//         this.auto_ui.txt_goldLabel.node.parent.active = moneyCount > 0;
//         this.auto_ui.txt_goldLabel.string = `${moneyCount}`;
//         this.auto_ui.txt_lvLabel.node.parent.active = rewards[0] > 0;
//         this.auto_ui.txt_lvLabel.string = `${rewards[0]}`;
//         this.auto_ui.txt_lanLabel.node.parent.active = rewards[1] > 0;
//         this.auto_ui.txt_lanLabel.string = `${rewards[1]}`;
//         this.auto_ui.txt_ziLabel.node.parent.active = rewards[2] > 0;
//         this.auto_ui.txt_ziLabel.string = `${rewards[2]}`;

//         this.auto_ui.node_boxBG.children[0].active = e.type === 0;
//         this.auto_ui.node_boxBG.children[1].active = e.type === 1;

//         const shopControlData = Excel.shopControl(1);
//         if (e.type === 0) {
//             this.auto_ui.btn_videoBuyBtn.interactable = shopControlData.box1BuyCount - HallMgrInstance.shopData.box1BuyCount > 0;
//         } else {
//             this.auto_ui.btn_videoBuyBtn.interactable = shopControlData.box2BuyCount - HallMgrInstance.shopData.box2BuyCount > 0;
//         }

//         this.auto_ui.txt_priceLabel.string = `${e.type === 0 ? shopControlData.boxPrice : shopControlData.bigBoxPrice}`;
//         if (e.type === 0) {
//             this.auto_ui.btn_buyBtn.interactable = PlayerDataMgr.globalData.diamond >= shopControlData.boxPrice;
//         } else {
//             this.auto_ui.btn_buyBtn.interactable = PlayerDataMgr.globalData.diamond >= shopControlData.bigBoxPrice;
//         }
//     }

//     /**
//      * 点击事件监听器
//      * @param e 点击事件
//      * 建议方法名: handleClick
//      */
//     _clickListener(e: cc.Button): void {
//         switch (e) {
//             case this.auto_ui.btn_buyBtn:
//                 if (this.infoData && this.infoData.clickCallBack) {
//                     this.infoData.clickCallBack(false);
//                     this._close();
//                 }
//                 break;
//             case this.auto_ui.btn_videoBuyBtn:
//                 if (this.infoData && this.infoData.clickCallBack) {
//                     this.infoData.clickCallBack(() => {
//                         this._close();
//                     });
//                 }
//                 break;
//             case this.auto_ui.btn_closeBtn:
//                 this._close();
//                 break;
//             case this.auto_ui.btn_lvIconBtn:
//                 this.ShowEquipInfo(1);
//                 break;
//             case this.auto_ui.btn_lanIconBtn:
//                 this.ShowEquipInfo(2);
//                 break;
//             case this.auto_ui.btn_ziIconBtn:
//                 this.ShowEquipInfo(3);
//                 break;
//         }
//     }

//     /**
//      * 显示装备信息
//      * @param e 装备类型
//      * 建议方法名: showEquipInfo
//      */
//     ShowEquipInfo(e: number): void {
//         UIManager.open(BundleNames.Home, UIView_Home.UI_BoxItemInfo, e);
//     }
// }

// export default UI_BoxInfo;

import UI_BoxInfo_UIBindings from "./UI_BoxInfo_UIBindings";
import UIViewBase from "./UIView";
import { Excel } from "./Excel";
import { HallMgr } from "./HallManager";
import UIManager from "./UIManager";
import { BundleNames } from "./BundleConfig";
import { PlayerDataMgr } from "./PlayerDataManager";
import { UIView_Home } from "./UIConfig_Home";

const { ccclass, property, inspector } = cc._decorator;

/**
 * 建议类名: BoxInfoView
 */
@ccclass
class ViewBoxInfo extends UIViewBase {
    @property(UI_BoxInfo_UIBindings)
    auto_ui: UI_BoxInfo_UIBindings = null;

    private infoData: any;

    /**
     * 显示礼盒信息
     * @param boxInfo 礼盒信息数据
     * 建议方法名: showBoxInfo
     */
    _show(boxInfo: any): void {
        this.infoData = boxInfo;
        const boxLevelData = Excel.shopBoxLevel(HallMgr.shopData.boxLevel + 1);

        if (boxInfo.type === 0) {
            this.auto_ui.txt_titleLabel.string = "普通礼盒";
        } else {
            this.auto_ui.txt_titleLabel.string = "精致礼盒";
        }

        const moneyAmount = boxInfo.type === 0 ? boxLevelData.moneyCount : boxLevelData.bigMoneyCount;
        const boxRewards = boxInfo.type === 0 ? boxLevelData.rewards : boxLevelData.bigRewards;

        this.auto_ui.txt_goldLabel.node.parent.active = moneyAmount > 0;
        this.auto_ui.txt_goldLabel.string = `${moneyAmount}`;
        this.auto_ui.txt_lvLabel.node.parent.active = boxRewards[0] > 0;
        this.auto_ui.txt_lvLabel.string = `${boxRewards[0]}`;
        this.auto_ui.txt_lanLabel.node.parent.active = boxRewards[1] > 0;
        this.auto_ui.txt_lanLabel.string = `${boxRewards[1]}`;
        this.auto_ui.txt_ziLabel.node.parent.active = boxRewards[2] > 0;
        this.auto_ui.txt_ziLabel.string = `${boxRewards[2]}`;

        this.auto_ui.node_boxBG.children[0].active = boxInfo.type === 0;
        this.auto_ui.node_boxBG.children[1].active = boxInfo.type === 1;

        const controlData = Excel.shopControl(1);
        if (boxInfo.type === 0) {
            this.auto_ui.btn_videoBuyBtn.interactable = controlData.box1BuyCount - HallMgr.shopData.box1BuyCount > 0;
        } else {
            this.auto_ui.btn_videoBuyBtn.interactable = controlData.box2BuyCount - HallMgr.shopData.box2BuyCount > 0;
        }

        this.auto_ui.txt_priceLabel.string = `${boxInfo.type === 0 ? controlData.boxPrice : controlData.bigBoxPrice}`;
        if (boxInfo.type === 0) {
            this.auto_ui.btn_buyBtn.interactable = PlayerDataMgr.globalData.diamond >= controlData.boxPrice;
        } else {
            this.auto_ui.btn_buyBtn.interactable = PlayerDataMgr.globalData.diamond >= controlData.bigBoxPrice;
        }
    }

    /**
     * 点击事件监听器
     * @param button 点击事件
     * 建议方法名: handleClick
     */
    _clickListener(button: cc.Button): void {
        switch (button) {
            case this.auto_ui.btn_buyBtn:
                if (this.infoData && this.infoData.clickCallBack) {
                    this.infoData.clickCallBack(false);
                    this._close();
                }
                break;
            case this.auto_ui.btn_videoBuyBtn:
                if (this.infoData && this.infoData.clickCallBack) {
                    this.infoData.clickCallBack(() => {
                        this._close();
                    });
                }
                break;
            case this.auto_ui.btn_closeBtn:
                this._close();
                break;
            case this.auto_ui.btn_lvIconBtn:
                this.showEquipInfo(1);
                break;
            case this.auto_ui.btn_lanIconBtn:
                this.showEquipInfo(2);
                break;
            case this.auto_ui.btn_ziIconBtn:
                this.showEquipInfo(3);
                break;
        }
    }

    /**
     * 显示装备信息
     * @param equipType 装备类型
     * 建议方法名: showEquipInfo
     */
    showEquipInfo(equipType: number): void {
        UIManager.open(BundleNames.Home, UIView_Home.UI_BoxItemInfo, equipType);
    }
}

export default ViewBoxInfo;